*/
#include <config.h>
+#include <Carbon/Carbon.h>
#include "gdk.h"
#include "gdkprivate-quartz.h"
{
g_return_if_fail (GDK_IS_WINDOW (window));
+ if (((GdkWindowObject *)window)->state & GDK_WINDOW_STATE_FULLSCREEN)
+ return;
+
move_resize_window_internal (window, x, y, -1, -1);
}
{
g_return_if_fail (GDK_IS_WINDOW (window));
+ if (((GdkWindowObject *)window)->state & GDK_WINDOW_STATE_FULLSCREEN)
+ return;
+
if (width < 1)
width = 1;
if (height < 1)
GdkWMDecoration decorations)
{
GdkWindowImplQuartz *impl;
- int style_mask;
+ int old_mask, new_mask;
NSView *old_view;
g_return_if_fail (GDK_IS_WINDOW (window));
if (decorations == 0 || GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP)
{
- style_mask = NSBorderlessWindowMask;
+ new_mask = NSBorderlessWindowMask;
}
else
{
- /* FIXME: Honor other GTK_DECOR_* flags. */
- style_mask = (NSTitledWindowMask | NSClosableWindowMask |
+ /* FIXME: Honor other GDK_DECOR_* flags. */
+ new_mask = (NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask | NSResizableWindowMask);
}
GDK_QUARTZ_ALLOC_POOL;
+ old_mask = [impl->toplevel styleMask];
+
/* Note, there doesn't seem to be a way to change this without
* recreating the toplevel. There might be bad side-effects of doing
* that, but it seems alright.
*/
- if ([impl->toplevel styleMask] != style_mask)
+ if (old_mask != new_mask)
{
+ NSRect rect;
+
old_view = [impl->toplevel contentView];
- impl->toplevel = [impl->toplevel initWithContentRect:[impl->toplevel frame]
- styleMask:style_mask
+ rect = [impl->toplevel frame];
+
+ /* Properly update the size of the window when the titlebar is
+ * added or removed.
+ */
+ if (old_mask == NSBorderlessWindowMask &&
+ new_mask != NSBorderlessWindowMask)
+ {
+ rect = [NSWindow frameRectForContentRect:rect styleMask:new_mask];
+ }
+ else if (old_mask != NSBorderlessWindowMask &&
+ new_mask == NSBorderlessWindowMask)
+ {
+ rect = [NSWindow contentRectForFrameRect:rect styleMask:old_mask];
+ }
+
+ impl->toplevel = [impl->toplevel initWithContentRect:rect
+ styleMask:new_mask
backing:NSBackingStoreBuffered
defer:NO];
[impl->toplevel setContentView:old_view];
+ [impl->toplevel setFrame:rect display:YES];
}
GDK_QUARTZ_RELEASE_POOL;
if (decorations)
{
- if ([impl->toplevel styleMask] & NSBorderlessWindowMask)
+ /* Borderless is 0, so we can't check it as a bit being set. */
+ if ([impl->toplevel styleMask] == NSBorderlessWindowMask)
{
*decorations = 0;
}
else
{
- /* FIXME: Honor the other GTK_DECOR_* flags. */
+ /* FIXME: Honor the other GDK_DECOR_* flags. */
*decorations = GDK_DECOR_ALL;
}
}
}
}
+#define FULLSCREEN_DATA "fullscreen-data"
+
+typedef struct
+{
+ gint x, y;
+ gint width, height;
+ GdkWMDecoration decor;
+} FullscreenSavedGeometry;
+
void
gdk_window_fullscreen (GdkWindow *window)
{
+ FullscreenSavedGeometry *geometry;
+ GdkWindowObject *private = (GdkWindowObject *) window;
+ GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
+ NSRect frame;
+
g_return_if_fail (GDK_IS_WINDOW (window));
+ g_return_if_fail (WINDOW_IS_TOPLEVEL (window));
- /* FIXME: Implement */
+ geometry = g_new (FullscreenSavedGeometry, 1);
+
+ geometry->x = private->x;
+ geometry->y = private->y;
+ geometry->width = impl->width;
+ geometry->height = impl->height;
+
+ if (!gdk_window_get_decorations (window, &geometry->decor))
+ geometry->decor = GDK_DECOR_ALL;
+
+ g_object_set_data_full (G_OBJECT (window),
+ FULLSCREEN_DATA, geometry,
+ g_free);
+
+ HideMenuBar ();
+
+ gdk_window_set_decorations (window, 0);
+
+ frame = [[NSScreen mainScreen] frame];
+ move_resize_window_internal (window,
+ 0, 0,
+ frame.size.width, frame.size.height);
+
+ gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN);
}
void
gdk_window_unfullscreen (GdkWindow *window)
{
+ FullscreenSavedGeometry *geometry;
+
g_return_if_fail (GDK_IS_WINDOW (window));
+ g_return_if_fail (WINDOW_IS_TOPLEVEL (window));
- /* FIXME: Implement */
+ geometry = g_object_get_data (G_OBJECT (window), FULLSCREEN_DATA);
+
+ if (geometry)
+ {
+
+ ShowMenuBar ();
+
+ move_resize_window_internal (window,
+ geometry->x,
+ geometry->y,
+ geometry->width,
+ geometry->height);
+
+ gdk_window_set_decorations (window, geometry->decor);
+
+ g_object_set_data (G_OBJECT (window), FULLSCREEN_DATA, NULL);
+
+ gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FULLSCREEN, 0);
+ }
}
void